/**
 * @param {number} x
 * @return {boolean}
 */
var n = function (digit) {
  return function (op) {
    return op ? op(digit) : digit;
  }
};
var zero = n(0);
var one = n(1);
var two = n(2);
var three = n(3);
var four = n(4);
var five = n(5);
var six = n(6);
var seven = n(7);
var eight = n(8);
var nine = n(9);

function plus(r) { return function (l) { return l + r; }; }
function minus(r) { return function (l) { return l - r; }; }
function times(r) { return function (l) { return l * r; }; }
function dividedBy(r) { return function (l) { return l / r; }; }
// +++++++++++++++++++++++++++++++++++++++++
function zero(x) {
  if (arguments[0] == null) { return '0' }
  else {
    return Math.floor(eval(`0${x}`))
  }
}
function one(x) {
  if (arguments[0] == null) { return '1' }
  else {
    return Math.floor(eval(`1${x}`))
  }
}
function two(x) {
  if (arguments[0] == null) { return '2' }
  else {
    return Math.floor(eval(`2${x}`))
  }
}
function three(x) {
  if (arguments[0] == null) { return '3' }
  else {
    return Math.floor(eval(`3${x}`))
  }
}
function four(x) {
  if (arguments[0] == null) { return '4' }
  else {
    return Math.floor(eval(`4${x}`))
  }
}
function five(x) {
  if (arguments[0] == null) { return '5' }
  else {
    return Math.floor(eval(`5${x}`))
  }
}
function six(x) {
  if (arguments[0] == null) { return '6' }
  else {
    return Math.floor(eval(`6${x}`))
  }
}
function seven(x) {
  if (arguments[0] == null) { return '7' }
  else {
    return Math.floor(eval(`7${x}`))
  }
}
function eight(x) {
  if (arguments[0] == null) { return '8' }
  else {
    return Math.floor(eval(`8${x}`))
  }
}
function nine(x) {
  if (arguments[0] == null) { return '9' }
  else {
    return Math.floor(eval(`9${x}`))
  }
}
// +++++++++++++++++++++++++++++++++++++++++
const
  id = x => x,
  number = x => (f = id) => f(x),
  [zero, one, two, three, four, five, six, seven, eight, nine] =
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(number),
  plus = x => y => y + x,
  minus = x => y => y - x,
  times = x => y => y * x,
  dividedBy = x => y => y / x;
// +++++++++++++++++++++++++++++++++++++++++
function zero(func) { return func ? func(0) : 0; };
function one(func) { return func ? func(1) : 1; };
function two(func) { return func ? func(2) : 2; };
function three(func) { return func ? func(3) : 3; };
function four(func) { return func ? func(4) : 4; };
function five(func) { return func ? func(5) : 5; };
function six(func) { return func ? func(6) : 6; };
function seven(func) { return func ? func(7) : 7; };
function eight(func) { return func ? func(8) : 8; };
function nine(func) { return func ? func(9) : 9; };

function plus(b) { return function (a) { return a + b; }; };
function minus(b) { return function (a) { return a - b; }; };
function times(b) { return function (a) { return a * b; }; };
function dividedBy(b) { return function (a) { return a / b; }; };
// +++++++++++++++++++++++++++++++++++++++++
'zero one two three four five six seven eight nine'.split(' ').forEach(
  (mth, num) => this[mth] = (f = val => val) => f(num)
)

let plus = (r) => (l) => l + r
let minus = (r) => (l) => l - r
let times = (r) => (l) => l * r
let dividedBy = (r) => (l) => l / r
// +++++++++++++++++++++++++++++++++++++++++
['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
  .forEach(function (name, n) {
    this[name] = function (f) { return f ? f(n) : n }
  });

function plus(n) { return function (a) { return a + n } }
function minus(n) { return function (a) { return a - n } }
function times(n) { return function (a) { return a * n } }
function dividedBy(n) { return function (a) { return a / n } }
// +++++++++++++++++++++++++++++++++++++++++
const [
  zero,
  one,
  two,
  three,
  four,
  five,
  six,
  seven,
  eight,
  nine
] = Array.from({ length: 10 }).map((item, i) => ((f) => f ? f(i) : i));

const [
  plus,
  minus,
  times,
  dividedBy
] = ['+', '-', '*', '/'].map(op => Function('b', `return a => a ${op} b`));

// +++++++++++++++++++++++++++++++++++++++++
['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'].forEach(function (funName, i) {
  this[funName] = function (operation) { return operation ? operation(i) : i };
});

function plus(operandRight) { return function (operandLeft) { return operandLeft + operandRight } }
function minus(operandRight) { return function (operandLeft) { return operandLeft - operandRight } }
function times(operandRight) { return function (operandLeft) { return operandLeft * operandRight } }
function dividedBy(operandRight) { return function (operandLeft) { return operandLeft / operandRight } }
// +++++++++++++++++++++++++++++++++++++++++
function zero(fn) { return fn ? fn(0) : 0 }
function one(fn) { return fn ? fn(1) : 1 }
function two(fn) { return fn ? fn(2) : 2 }
function three(fn) { return fn ? fn(3) : 3 }
function four(fn) { return fn ? fn(4) : 4 }
function five(fn) { return fn ? fn(5) : 5 }
function six(fn) { return fn ? fn(6) : 6 }
function seven(fn) { return fn ? fn(7) : 7 }
function eight(fn) { return fn ? fn(8) : 8 }
function nine(fn) { return fn ? fn(9) : 9 }

function plus(n) { return function (v) { return v + n } }
function minus(n) { return function (v) { return v - n } }
function times(n) { return function (v) { return v * n } }
function dividedBy(n) { return function (v) { return v / n } }
// +++++++++++++++++++++++++++++++++++++++++

function plus(a) { return '+' + a }
function minus(a) { return '-' + a }
function times(a) { return '*' + a }
function dividedBy(a) { return '/' + a }

console.log(seven(times(five())))
console.log(four(plus(nine())))
console.log(eight(minus(three())))
console.log(six(dividedBy(two())))

console.log(eight(dividedBy(three())))